package com.ncu.cloundeoffice.controller;


import com.ncu.cloundeoffice.pojo.ResponseResult;
import com.ncu.cloundeoffice.pojo.TDepartment;
import com.ncu.cloundeoffice.service.TDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/basic/department")
public class TDepartmentController {

    @Autowired
    private TDepartmentService tDepartmentService;

    /**
     * 查找所有的部门
     * @return
     */
    @GetMapping("/")
    public List<TDepartment> getAllTDepartments(){
        return tDepartmentService.getAllTDepartments();
    }

    /**
     * 添加部门
     * @param tDepartment
     * @return
     */
    @PostMapping("/")
    public ResponseResult addDep(@RequestBody TDepartment tDepartment){
        return tDepartmentService.addDep(tDepartment);
    }

    /**
     * 删除部门
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public ResponseResult deleteDep(@PathVariable("id") int id){
        return tDepartmentService.deleteDep(id);
    }
}
